package com.nycreativity.elecreativity.entity.param

import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonInclude
import java.io.Serializable
import java.util.*
import javax.validation.Valid
import java.util.function.Consumer
import java.util.function.Predicate
import java.util.function.UnaryOperator


/**
 * @description 可验证的集合
 * @author sxt
 * @date 2021/3/14 5:21 下午
 * @version 1.0
 */
class ValidateList<T>(override val size: Int = 0) : ArrayList<T>(), Serializable {

    @field:Valid
    val list: ArrayList<T> = ArrayList(size)

    override fun contains(element: T): Boolean {
        return list.contains(element)
    }

    override fun containsAll(elements: Collection<T>): Boolean {
        return list.containsAll(elements)
    }

    override fun get(index: Int): T {
        return list.get(index)
    }

    override fun indexOf(element: T): Int {
        return list.indexOf(element)
    }

    override fun isEmpty(): Boolean {
        return list.isEmpty()
    }

    override fun iterator(): MutableIterator<T> {
        return list.iterator()
    }

    override fun lastIndexOf(element: T): Int {
        return list.lastIndexOf(element)
    }

    override fun listIterator(): MutableListIterator<T> {
        return list.listIterator()
    }

    override fun listIterator(index: Int): MutableListIterator<T> {
        return list.listIterator(index)
    }

    override fun subList(fromIndex: Int, toIndex: Int): MutableList<T> {
        return list.subList(fromIndex, toIndex)
    }

    override fun add(element: T): Boolean {
        return list.add(element)
    }

    override fun add(index: Int, element: T) {
        list.add(index, element)
    }

    override fun addAll(elements: Collection<T>): Boolean {
        return list.addAll(elements)
    }

    override fun addAll(index: Int, elements: Collection<T>): Boolean {
        return list.addAll(index, elements)
    }

    override fun clear() {
        list.clear()
    }

    override fun remove(element: T): Boolean {
        return list.remove(element)
    }

    override fun removeAll(elements: Collection<T>): Boolean {
        return list.removeAll(elements)
    }

    override fun retainAll(elements: Collection<T>): Boolean {
        return list.retainAll(elements)
    }

    override fun forEach(action: Consumer<in T>?) {
        list.forEach(action)
    }

    override fun spliterator(): Spliterator<T> {
        return list.spliterator()
    }

    override fun toArray(): Array<Any> {
        return list.toArray()
    }

    override fun <T : Any?> toArray(a: Array<out T>): Array<T> {
        return list.toArray(a)
    }

    override fun removeIf(filter: Predicate<in T>): Boolean {
        return list.removeIf(filter)
    }

    override fun removeAt(index: Int): T {
        return list.removeAt(index)
    }

    override fun set(index: Int, element: T): T {
        return list.set(index, element)
    }

    override fun replaceAll(operator: UnaryOperator<T>) {
        list.replaceAll(operator)
    }

    override fun clone(): Any {
        return list.clone()
    }

    override fun trimToSize() {
        list.trimToSize()
    }

    override fun ensureCapacity(minCapacity: Int) {
        list.ensureCapacity(minCapacity)
    }
}
